<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
<%@ include file="/website/layout/tag.jsp"%>
<script type="text/javascript">
	$(document).ready(
		function() {
			//事件注册.
			$("#addBtn").click(addArticle);
			$("#searchBtn").click(searchArticle);
			$("#modifyBtn").click(modifyArticle);
			$("#deployBtn").click(
				function() {
					changeBookSta("1");
				}
			);
			$("#cancelBtn").click(
				function() {
					changeBookSta("0");
				}
			);
			
			//checkbox控件事件注册.
			$("[name='chkAll']").each(
				function() {
					$(this).click(function() {
						checkAll("chkAll", "chkEach");
					});
				}
			);
			$("[name='chkEach']").each(
				function() {
					$(this).click(function() {
						checkEach("chkAll", "chkEach");
					});
				}
			);
			
			//设置左菜单对应菜单CSS为选中状态.
			changeToActiveCss("menu_2010");
			
			//消息显示.
			var msg = '<c:out value="${msg}"/>';
			if (msg != "") {
				alert(msg);
			}
		}
	);
	
	function searchArticle() {
		$("#searchForm").submit();
	}
	
	function addArticle() {
		window.location.href='${pageContext.request.contextPath}/content/enterArticleModify.do?oper=new';
	}
	
	function modifyArticle() {
		var checkObjs = $(":checkbox[name='chkEach']:checked");
		var len = checkObjs.length;
		if (len == 0) {
			alert("请选择要编辑的文章.");
			return false;
		}
		
		if (len > 1) {
			alert("请只选择一条文章数据.");
			return false;
		}
		
		window.location.href='${pageContext.request.contextPath}/content/enterArticleModify.do?oper=modify&sysId=' + checkObjs[0].value;
	}
	
	function changeArticleSta(newStatus) {
		var checkObjs = $(":checkbox[name='chkEach']:checked");
		var len = checkObjs.length;
		if (len == 0) {
			alert("请选择要修改的文章.");
			return false;
		}
		
		var articleIds = "";
		checkObjs.each(
			function() {
				articleIds += $(this).val() + ",";
			}
		);
		
		if(confirm("确定要修改文章的发布状态吗?")) {
			var action = "${pageContext.request.contextPath}/content/changeArticleSta.do";
			action += "?articleIds=" + articleIds + "&newStatus=" + newStatus;
			$("#searchForm").attr("action", action);
			$("#searchForm").submit();
		}
	}

</script>
<div id="content_right">
	<div style="width:100%;height:35px;line-height:35px;text-align:left;background-color:#F5FAFA;font-weight:bold; ">内容管理 > 网站内容管理 > 文章管理</div>
	<div id="searchArea">
		<table width="100%" cellspacing="0">
			<tr>
				<td style="width:60px; text-align:right;">所属栏目:</td>
				<td style="width:100px; text-align:left;">
					<select style="width:90px ">
						<option value="1" selected>全部</option>
						<option value="2">最新公告</option>
					</select>
				</td>
				<td style="width:60px; text-align:right;">文章标题:</td>
				<td style="width:180px; text-align:left;"></td>
				<td width="60px" align="right">发布日期:</td>
				<td style="width:240px; text-align:left;">
					<input type="text" style="width:70px; " name="testInput" value=""/>-<input type="text" style="width:70px; " name="testInput" value=""/>(YYYY/MM/DD)
				</td>
				<td style="width:60px; text-align:right;">是否发布:</td>
				<td style="width:60px; text-align:left;">
				</td>
				<td></td>
			</tr>
			<tr>
				<td colspan="9">
					<div class="buttons" style="float:right; margin-right:40px;">
						<a id="searchBtn" href="#">
							<img src="../images/btn_search.gif" alt=""/> 
							检索
						</a>
					</div>
				</td>
			</tr>
		</table>
	</div>
	<div id="btnArea">
		<div class="buttons">
			<a href="../content/content_modify.html" class="regular"><!-- class="regular"-->
				<img src="../images/btn_apply.png" alt=""/> 
				添加
			</a>
			<a href="../content/content_modify.html" class="regular"><!-- class="regular"-->
				<img src="../images/btn_textfield_key.png" alt=""/> 
				修改
			</a>
			<a href="" class="regular"><!-- class="regular"-->
				<img src="../images/btn_cross.png" alt=""/> 
				删除
			</a>
			<a id="deployBtn" href="#">
				<img src="../images/btn_cross.png" alt=""/> 
				发布文章
			</a>
			<a id="cancelBtn" href="#">
				<img src="../images/btn_cross.png" alt=""/> 
				撤下文章
			</a>
		</div>
	</div>
	<div style="clear:both; "></div>
	<div id="resultArea" style="height:400px; ">
		<table class="dataTable" cellspacing="0"> 
			<tr> 
			<th scope="col" width="26px;"><input type="checkbox" name="chkAll"/></th> 
			<th scope="col" width="80px">所属栏目</th> 
			<th scope="col" width="320px">文章标题</th>  
			<th scope="col" width="60px">是否发布</th> 
			<th scope="col"></th>
			</tr> 
			<tr> 
			<td class="row"> <input type="checkbox" name="chkEach" value="#"/></td>
			<td class="row">#</td> 
			<td class="row">#</td> 
			<td class="row">#</td> 
			<td class="row"></td>
			</tr> 
		</table> 
	</div>
</div>

